<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改展会名单')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-eventRegion-edit" th:object="${eventRegion}">
        <div class="row">
            <div class="col-sm-12">
                <input id="regionId" name="regionId" type="hidden" th:field="*{regionId}"/>
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">展会名称：</label>
                    <div class="col-sm-8">
                        <select id="rosterId" name="rosterId" class="form-control m-b">
                            <option th:each="post:${eventRoster}" th:value="${post.rosterId}" th:text="${post.eventName}" th:field="*{rosterId}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">区域编号：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="areaNum" id="areaNum" th:field="*{areaNum}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">摊位编号：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="boothNum" id="boothNum" th:field="*{boothNum}" required>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "system/eventRegion";

    $('input').on('ifChanged', function(obj){
        var type = $(this).val();
        var checked = obj.currentTarget.checked;
        if (type == 1) {
            if (checked) {
                $._tree.expandAll(true);
            } else {
                $._tree.expandAll(false);
            }
        } else if (type == "2") {
            if (checked) {
                $._tree.checkAllNodes(true);
            } else {
                $._tree.checkAllNodes(false);
            }
        } else if (type == "3") {
            if (checked) {
                $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" };
            } else {
                $._tree.setting.check.chkboxType = { "Y": "", "N": "" };
            }
        }
    })

    function edit() {
        var rosterId = document.getElementById("rosterId").value;
        var areaNum = document.getElementById("areaNum").value;
        var boothNum = document.getElementById("boothNum").value;
        var regionId = document.getElementById("regionId").value;
        $.ajax({
            cache : true,
            type : "POST",
            url : prefix + "/edit",
            data : {
                "regionId": regionId,
                "rosterId": rosterId,
                "areaNum": areaNum,
                "boothNum": boothNum
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }
</script>
</body>
</html>
